package
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;
	import flash.text.TextField;
	import flash.text.TextFieldType;
	
	public class TestTextField4 extends Sprite
	{
		private		var		_field:TextField = null;
		private		var		_highlight:Sprite = null;
		
		public function TestTextField4()
		{
			super();
			
			_field = new TextField();
			_field.border = true;
			_field.type = TextFieldType.INPUT;
			_field.wordWrap = true;
			_field.text = "abcdef,addfsalfjsd,d dsfsdjfss,sfksjslas";
			
			this.addChild(_field);
			_field.addEventListener(MouseEvent.CLICK, onClick);
			
			_highlight = new Sprite();
			this.addChild(_highlight);
			
			trace(_field.numLines);
		}
		
		public	function	onClick(evt:MouseEvent):void{
			var charIndex:int = _field.getCharIndexAtPoint(this.mouseX, this.mouseY);
			var rect:Rectangle = _field.getCharBoundaries(charIndex);
			trace(charIndex);
			this._highlight.graphics.clear();
			this._highlight.graphics.lineStyle(0,0,0);
			this._highlight.graphics.beginFill(0x00ffff,0.25);
			this._highlight.graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
			this._highlight.graphics.endFill();
			
			
		}
	}
}